<template>
	<view>
		<u-empty text="还没有发布的评论" mode="list" v-if="list.length==0" style="margin-top: 400rpx;"></u-empty>
		<u-card :title="item.title" :sub-title="$u.timeFormat(item.created, 'yyyy年mm月dd日')" v-for="(item, index) in  list"
		 :key="item.id">
			<view class="" slot="body">
				{{item.content}}
			</view>
			<view class="" slot="foot">
				<u-button type="error" @click="delcom(item)">删除</u-button>
			</view>
		</u-card>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	export default {
		onLoad() {
			this.getDate();
		},
		computed: {
			...mapGetters({
				info: "vuex_user",
				token: "vuex_token"
			})
		},
		data() {
			return {
				list: []
			}
		},
		methods: {
			getDate() {
				this.$u.api.postgetcomlist({
					username: this.info.username
				}).then(res => {
					console.log(res.data)
					this.list = []
					this.list = res.data
				})
			},
			delcom(item) {
				this.$u.api.postdelcom({
					username: this.info.username,
					id: item.id
				}).then(res => {
					console.log(res)
					this.getDate()
				})
			}
		}
	}
</script>

<style>

</style>
